<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>ZyAdmin管理系统</title>
    <meta content="ZyAdmin、后台管理框架、大数据、app" name="description"/>
    <meta content="ZyAdmin" name="author"/>
    <meta name="keywords" content="ZyAdmin 后台管理框架 大数据 app"/>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" th:href="${StaticResourcePath}+@{'layui/css/font.css'}">
    <link rel="stylesheet" th:href="${StaticResourcePath}+@{'layui/css/login.css'}">
    <link rel="stylesheet" th:href="${StaticResourcePath}+@{'layui/css/xadmin.css'}">
</head>
<body style="width: 100%;height:100%;background: url(/images/index_bg2.jpg) no-repeat center;background-size: cover;overflow: hidden;">

<div class="login layui-anim layui-anim-up">
    <div class="message">ZyAdmin 管理登录</div>
    <div id="darkbannerwrap"></div>

    <form method="post" class="layui-form">
        <input name="username" id="username" placeholder="用户名" type="text" lay-verify="required" class="layui-input">
        <hr class="hr15">
        <input name="password" id="password" lay-verify="required" placeholder="密码" type="password" class="layui-input">
        <hr class="hr15">
        <input type="checkbox" id="recordPwd" name="recordPwd" lay-skin="primary" title="记住密码">
        <hr class="hr15">
        <input value="登录" lay-submit lay-filter="login" style="width:100%;" type="submit">
        <hr class="hr20">
        <div>
            <a href="https://blog.csdn.net/zhuyu19911016520" target="_blank">朱宇</a> 修能提供技术支持。
        </div>
    </form>
</div>

<!-- 底部固定区域
<div style="position: absolute;bottom: 0;width: 100%;text-align: center;background-color: #f1f1f1;height: 32px;line-height: 32px;">
    © 朱宇 - 修能信息提供技术支持
</div> -->
<script type="text/javascript" th:src="${StaticResourcePath}+@{'js/jquery.min.js'}" charset="utf-8"></script>
<script type="text/javascript" th:src="${StaticResourcePath}+@{'layui/lib/layui/layui.js'}" charset="utf-8"></script>
<script type="text/javascript" th:src="${StaticResourcePath}+@{'js/base64.js'}" charset="utf-8"></script>
<script type="text/javascript" th:src="${StaticResourcePath}+@{'js/common.js'}" charset="utf-8"></script>
<script type="text/javascript" th:inline="javascript">
    $(function () {

        layui.use(['form', 'layer'], function () {
            var form = layui.form,
                layer = layui.layer;

            //判断是否记住了密码
            var remeberLoginInfo = localStorage.getItem('loginInfo');
            if(remeberLoginInfo && remeberLoginInfo != ""){
                remeberLoginInfo = JSON.parse(remeberLoginInfo);
                getById("username").value = Base64.decode(remeberLoginInfo.userAccount);
                getById("password").value = Base64.decode(remeberLoginInfo.userPwd);
                $("#recordPwd").prop("checked", true);
                form.render();
            }

            //监听提交
            form.on('submit(login)', function (data) {
                //console.log(data);
                //对用户名和密码进行加密
                var userAccount = Base64.encode(data.field.username);
                var userPwd = Base64.encode(data.field.password);
                var recordPwd = data.field.recordPwd;
                if(recordPwd && recordPwd == "on"){
                    //勾选了记住密码
                    var loginInfo = {userAccount : userAccount , userPwd : userPwd};
                    localStorage.setItem('loginInfo',JSON.stringify(loginInfo));
                }else{
                    //清空已记住的密码
                    localStorage.removeItem("loginInfo");
                }

                //发起请求
                new AjaxRequest({
                    type: "POST",
                    url: webroot + "sys/login/login?platform=Pc&userAccount=" + userAccount + "&userPwd=" + userPwd,
                    isShowLoader: true,
                    success: function (res) {
                        console.log(res);
                        if (res) {
                            if (res.resultCode == "0000" && res.resultObj != "") {
                                setCookie("token", res.resultObj);
                                window.location.href = "/sys/main";
                            } else {
                                layer.alert(res.resultMessage, {icon: 2})
                            }
                        }
                    }
                });
                return false;
            });
        });
    })
</script>
</body>
</html>